package com.imooc.sell.config;

import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * create by song on 2018/3/20
 * To change this template use File | Settings | File Templates.
 */

@Component
public class WechatOpenConfig {

    @Autowired
    private WechatAccountConfig wechatAccountConfig;

    @Bean
    public WxMpService wxOpenService(){
        WxMpService wxOpenService  = new WxMpServiceImpl ();
        wxOpenService.setWxMpConfigStorage ( wxMpConfigStorage () );
    }

    @Bean
    public WxMpConfigStorage wxMpConfigStorage(){
        WxMpInMemoryConfigStorage wxMpInMemoryConfigStorage = new WxMpInMemoryConfigStorage ();
        wxMpInMemoryConfigStorage.setAppId ( wechatAccountConfig.getOpenAppId () );
        wxMpInMemoryConfigStorage.setSecret ( wechatAccountConfig.getOpenAppSecret () );
        return wxMpInMemoryConfigStorage;
    }

}
